<html>
 <head>
    <title>[var.TITLE]</title>
    <link href="[var.ROOT_CSS_DIR]/main.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <link href="[var.ROOT_CSS_DIR]/facet/style.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <script type="text/javascript" src="[var.ROOT_DIR]js/common.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/doiMenuDOM.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/functions.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmenu.php"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmenu.cfg"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmasks.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jquery.min.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsformgridnew.js"></script>
 </head>
 <body bgcolor="FFFFFF" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
    <table border="0" cellspacing="0" cellpadding="0" width="100%" align="[var.POSITION]">
        <tr height="100%">
            <td>
            <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
                <tr valign="top">
                    <td width="100%">
                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="FacetHeaderContent" align="left">.:Activity Lookup:. </td>
                            </tr>
                        </table>
                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="content2">
                                    <table border="0" cellspacing="0" cellpadding="0">
                                    <form  method="post" action="[var.FileName]?FormName=[var.FormName]&[var.PreserveGet]">
                                        
                                        <tr>
                                            <td class="fieldCaption">Services Name</td>
                                            <td class="fieldCaption">:</td>
                                            <td>
                                            <input type="text" name="nameSearch" size="35" maxlength="50" class="input" value="[var.FNama]">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="menuHeader"></td>
                                            <td class="menuHeader"></td>
                                            <td align="right">
                                            <!--input type="button" value="Add New" class="button" onclick="AddNew();"-->
                                            <input type="submit" name="Action" value="Search" class="button" >
                                            </td>
                                        </tr>
                                    </form>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td >&nbsp;</td>
                            </tr>
                        </table>
                        <table border="0" cellspacing="0" cellpadding="0" width="100%">
                            <tr>
                              <td>
                         <!-- GRID SECTION -->
                                    <table border="0" width="100%" cellpadding="3" cellspacing="1" class="FacetFormTABLE" align="left">
                                    <form method=post name="[var.HTMLGridList]" >
                                      <tr>
                                        <td nowrap class="FacetColumnTD" align="center">No.</td>
                                        <td nowrap class="FacetColumnTD" align="center">Services Name</td>
                                        <td nowrap class="FacetColumnTD" align="center">Services Quantity</td>
                                        <td nowrap class="FacetColumnTD" align="center">Currency</td>
                                        <td nowrap class="FacetColumnTD" align="center">Total Amount</td>
                                      </tr>

                                      <tr>
                                        <td nowrap class="FacetDataTD">[blg.#]</td>
                                        <td class="FacetDataTD"><a href="javascript:if(checkData('[blg.survey_act_id]', '[blg.curr]') == 1) {GetCustomer('[blg.survey_act_id]', '[blg.actname]', '[blg.qty]', '[blg.curr]', '[blg.rate]', '[blg.amount]', '[blg.base_amount]', '[blg.tax_rate]', '[blg.tax_amount]', '[blg.total_amount]', '[blg.tax_amount_usd]', '[blg.total_amount_usd]', '[blg.amount_remain]', '[blg.budget_remain]', '[blg.qty_remain]');}">[blg.actname;block=tr;]</a></td>
                                        <td class="FacetDataTD">[blg.qty]</td>
                                        <td class="FacetDataTD">[blg.curr]</td>
                                        <td class="FacetDataTD">[blg.total_amount;frm='0,000.00']</td>
                                      </tr>

                                      <tr>
                                        <td colspan="10" class="FacetDataTD">[blg;block=tr;nodata]No records</td>
                                      </tr>

                                      <tr>
                                        <td colspan="10" nowrap class="FacetColumnTD">[tbs_check.1;block=tr;if [var.RecCnt]!=0]
                                            <table border="0" align="left" cellpadding="0" cellspacing="0">
                                              <tr align="center">[tbs_check.1;block=table;if [var.RecCnt]!=0]
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.first;endpoint;friend2=a]&[var.PreserveGet]">|&lt;</a></td> 
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.prev;endpoint;friend2=a]&[var.PreserveGet]">&lt;</a></td> 
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.page;block=td]&[var.PreserveGet]">[nv.page]</a></td> 
                                                <td width="16" bgcolor="#B7B3B7"><strong>[nv.page;block=td;currpage]</strong></td> 
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.next;endpoint;friend2=a]&[var.PreserveGet]">&gt;</a></td> 
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.last;endpoint;friend2=a]&[var.PreserveGet]">&gt;|</a></td> 
                                              </tr> 
                                            </table>  
                                        </td>
                                      </tr>
                                      </form>
                                    </table>
                        <!-- GRID SECTION -->
                               </td>
                            </tr>
                            <tr>
                              <td>

                              &nbsp;
                              </td>
                            </tr>
                            </table>
                    </td>
                </tr>
            </table>

            </td>
        </tr>
    </table>
 </body>
<script>


 var Address;
 var NPWP;

 function SetOther(addr,npwp) {
    Address = addr;
    NPWP = npwp;
 }

 //function GetCustomer(survey_act_id, survey_services, qty, curr, rate, amount, base_amount, tax_rate, tax_amount, total_amount, budget_remain, qty_activity_remain, tax_amount_usd, total_amount_usd, amount_remain, skada_act) {
 
 function GetCustomer(survey_act_id, survey_services, qty, curr, rate, amount, base_amount, tax_rate, tax_amount, total_amount, tax_amount_usd, total_amount_usd, amount_remain, budget_remain, qty_survey_remain) {
 
 oMask = new Mask('#,###.#0', 'number');

 var BufferOpener;
 var no_urut = [var.no_urut];
 var total = 0;


    for(i=1;i<=10;i++){
        eval("var TotalAmount = window.opener.document.[var.FormName].jumlah"+i+".value");

        if(TotalAmount == "") {
            TotalAmount = 0;
        }

        TotalAmount = String(TotalAmount);
        TotalAmount = (TotalAmount.replace(/,/g, "")) * 1;

            //alert("TotalAmount: " + TotalAmount);
        total = total + TotalAmount;
        //alert("total: " + total);
    }

    //alert("total_amount: " + total_amount);

    budget_remain = String(budget_remain);
    budget_remain = (budget_remain.replace(/,/g, "")) * 1;
		
		total = total + budget_remain;
		
    //total = total + total_amount;
    //alert("total: " + total);
    var maskTotalAmount = oMask.format(total);

    window.opener.document.[var.FormName].total_trans.value = maskTotalAmount;


    var tax_arr = tax_rate.split("-");
    var tax_val = tax_arr[0] * 1;
    var tax_text = tax_arr[1];

    var tax_percent = tax_val * 100 + "% " + tax_text;

     BufferOpener = window.opener.document.body.innerHTML;

     var maskRate = oMask.format(rate);
     var maskAmount = oMask.format(amount);
     var maskTaxRate = oMask.format(tax_rate);
     var maskTaxAmount = oMask.format(tax_amount);
     var maskTaxAmountUsd = oMask.format(tax_amount_usd);  
     var maskTotalAmount = oMask.format(total_amount);
     var maskBudgetRemain = oMask.format(budget_remain);
     var maskAmountRemain = oMask.format(amount_remain);
          
//alert(maskBudgetRemain);
     if(no_urut != "")
     {
         //window.opener.document.[var.FormName].survey_id[var.no_urut].value = survey_id; 
         window.opener.document.[var.FormName].survey_act_id[var.no_urut].value = survey_act_id;         
         window.opener.document.[var.FormName].uraian[var.no_urut].value = survey_services; 
         window.opener.document.[var.FormName].qty_activity[var.no_urut].value = qty;      
         window.opener.document.[var.FormName].curr[var.no_urut].value = curr; 
         window.opener.document.[var.FormName].qty_buffer[var.no_urut].value = qty_survey_remain; 

         

		if(curr == "IDR")
		{
			maskRate = String(maskRate);
			maskRate = (maskRate.replace(/,/g, "")) * 1;

			base_amount = qty_survey_remain * maskRate;
	 
		} else if(curr == "USD")
		{
			maskRate = String(maskRate);
			maskRate = (maskRate.replace(/,/g, "")) * 1;

			base_amount = qty_survey_remain * maskRate * [var.kursUSD];
		}

		var maskBaseAmount = oMask.format(base_amount);


         window.opener.document.[var.FormName].base_amount[var.no_urut].value = maskBaseAmount ;
         window.opener.document.[var.FormName].base_amount_buffer[var.no_urut].value = maskBaseAmount ;
        
         window.opener.document.[var.FormName].tax_desc[var.no_urut].value = tax_percent;
         window.opener.document.[var.FormName].tax_rate[var.no_urut].value = tax_rate;


         ///window.opener.document.[var.FormName].jumlah[var.no_urut].value = maskTotalAmount;
				window.opener.document.[var.FormName].jumlah[var.no_urut].value = maskBudgetRemain;
        window.opener.document.[var.FormName].max_amount[var.no_urut].value = maskBudgetRemain;

         if(curr == "USD") {
            window.opener.document.[var.FormName].tax_amount[var.no_urut].value = maskTaxAmountUsd;
            window.opener.document.[var.FormName].tax_amount_buffer[var.no_urut].value = maskTaxAmountUsd;
        } else {
            window.opener.document.[var.FormName].tax_amount[var.no_urut].value = maskTaxAmount;
            window.opener.document.[var.FormName].tax_amount_buffer[var.no_urut].value = maskTaxAmount;
        }
     }

     else
     {
         window.opener.document.[var.FormName].act_nr_id.value = act_nr_id;
         window.opener.document.[var.FormName].actcode.value = actcode;
         window.opener.document.[var.FormName].actname.value = actname;
     }



     self.close();
 }



 function AddNew() {
    self.location.replace('ais_transaction_debtur.php?PageMode=Form');
 }



 function checkData(val, curr){
    var result = 1;

    for(i=1;i<=10;i++){
        if( val == eval("window.opener.document.[var.FormName].survey_act_id"+i+".value")){
            alert("Data yang anda pilih sudah termasuk di dalam list yang akan di BS");
            result = 0;
            break;
        }

/*        if( eval("window.opener.document.[var.FormName].curr"+i+".value") != "" & curr != eval("window.opener.document.[var.FormName].curr"+i+".value")){
            alert("Terdapat perbedaan currency pada antara data yang anda pilih dengan data yang ada di list");
            result = 0;
            break;
        } */


    }
    
//alert(result);


    return result;

 }
</script>
</html>
